package com.xiaoxi.observermode.generator;

import com.xiaoxi.observermode.observer.Observer;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author xiaoxi
 * @ProjectName design_mode
 * @PackageName com.xiaoxi.observermode.generator
 * @ClassName NumberGenertor
 * @Description TODO
 * @Date 2023/3/27 15:45
 * @Version 1.0
 */
public abstract class NumberGenerator {

    private List<Observer> observerList = new ArrayList<>();

    public void addObserver(Observer observer) {
        observerList.add(observer);
    }

    public void deleteObserver(Observer observer) {
        observerList.remove(observer);
    }

    public void notifyObservers() {
        for (Observer observer : observerList) {
            observer.update(this);
        }
    }

    public abstract Integer getNumber();
    public abstract void execute();

}
